///////////////////////////////////////////////////////////////////////////////
//
// lighthouse3D - 3D Software Library
//
// File: COBJFileHandler.h
//
///////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2003-2013 Marcus Reinhardt
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
//
///////////////////////////////////////////////////////////////////////////////
//
// You can find a copy of the GNU General Public License (gpl.txt) in the
// directory of the library.
//
///////////////////////////////////////////////////////////////////////////////

#ifndef _COBJileHandler_H_
#define _COBJFileHandler_H_

#include <iostream>

#include "CBasicClasses.h"
#include "CMeshStorage.h"

///////////////////////////////////////////////////////////////////////////////
// class COBJFileHandler : A class to load OBJ Files
///////////////////////////////////////////////////////////////////////////////

#define disableDebugging                       false

//! A class to import object files created with maya (*.obj)

class COBJFileHandler
{

public:

    COBJFileHandler();
    ~COBJFileHandler();

    bool loadOBJFile(const char *fname, CMeshStorage *storageHandler);
	void scanFaceTriple(char *fname, int *f0, int *f1, int *f2);

	////////////////////////////////////////////////////////////////////////////
    // The following routines are for debugging! They are disabled for the
    // moment. If you enable them you will get a lots of information about the
    // OBJ file.
    ////////////////////////////////////////////////////////////////////////////
	void writeDebugText(char *text) { if (!disableDebugging) fprintf(logFile, text); }
	void writeDebugInt(int i) { if (!disableDebugging) fprintf(logFile, "%i", i); }
	void writeDebugFloat(float f) { if (!disableDebugging) fprintf(logFile, "%f", f); }
	void flushDebug() { if (!disableDebugging) fflush(logFile); }

private:

    FILE *logFile;
    
    CMeshStorage *pMeshStorage;

	char fileLine[256];

	int statObjects;

};

#endif
